//
//  TKYMessageController.m
//  StationHouseHelper
//
//  Created by apple on 2018/6/26.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYMessageController.h"
#import "TKYMessageCell.h"
#import "TKYMessageModel.h"
#import "TKYMessageDescribeCell.h"
#import "TKYMessagePhotoOrVideoCell.h"
#import "TKYMeansCell.h"
#define KMessageCelID @"TKYMessageCell"
//问题描述
#define KMessageDescribeCellID @"TKYMessageDescribeCell"
//显示视频或图片
#define KMessagePhotoOrVideoCellID @"TKYMessagePhotoOrVideoCell"
//资料
#define KMeansCellID   @"TKYMeansCell"
@interface TKYMessageController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong)BaseTabelView *tabelView;

@end

@implementation TKYMessageController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.tabelView];
    // Do any additional setup after loading the view from its nib.

}




#pragma  mark -- UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 8;
    }else if (section == 1){
        return 3;
    }else{
        return 4;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.00001;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 0.00001;
    }else{
        return 30;
    }
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return @"";
    }else if (section == 1){
        return @"资料模型";
    }else{
        return @"相关人员";
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TKYMessageCell *messageCellcell = [tableView dequeueReusableCellWithIdentifier:KMessageCelID];
    TKYMessageDescribeCell *desCell = [tableView dequeueReusableCellWithIdentifier:KMessageDescribeCellID];
    if (indexPath.section == 0) {
        if (indexPath.row == 0 || indexPath.row == 1 || indexPath.row == 2 || indexPath.row == 3 ||  indexPath.row == 7) {
            messageCellcell.messageModel = [self setSectionOneData][indexPath.row];
            return messageCellcell;
        }else if(indexPath.row == 4 ){
            
            desCell.tltleLabel.text = @"问题描述";
            desCell.contentLabel.text = @"问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述问题描述";
            return desCell;
        }else if(indexPath.row == 5) {
            desCell.tltleLabel.text = @"措施要求";
            desCell.contentLabel.text = @"措施要求措施要求措施要求措施要求措施要求措施要求措施要求措施要求措施要求措施要求";
            return desCell;
        }else{
            TKYMessagePhotoOrVideoCell *videoCell = [tableView dequeueReusableCellWithIdentifier:KMessagePhotoOrVideoCellID];
            videoCell.bimButton.hidden = YES;

            return videoCell;
        }
    }else if (indexPath.section == 1){
        if (indexPath.row == 0) {
            TKYMeansCell *meansCell = [tableView dequeueReusableCellWithIdentifier:KMeansCellID];
            return meansCell;
        }else if (indexPath.row == 1){
            TKYMessagePhotoOrVideoCell *videoCell = [tableView dequeueReusableCellWithIdentifier:KMessagePhotoOrVideoCellID];
            [videoCell.bimButton addTarget:self action:@selector(shoBIMAction:) forControlEvents:UIControlEventTouchUpInside];
            return videoCell;
        }else{
            //TKYMessageCell *messageCellcell = [tableView dequeueReusableCellWithIdentifier:KMessageCelID];
            messageCellcell.titleLabel.text = @"分部分项";
            messageCellcell.contentLabel.text = @"1/4/f-01";
            return messageCellcell;
        }
    }else{
        
        messageCellcell.messageModel = [self setPersonnelData][indexPath.row];
         return messageCellcell;
    }
}

#pragma mark-- 查看BIM
- (void)shoBIMAction:(UIButton *)button{
#warning 查看bim事件
    NSLog(@"查看BIM");
}

- (BaseTabelView *)tabelView{
    if (_tabelView == nil) {
        _tabelView = [[BaseTabelView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - MyNavBarHeight - kHeightScale *50) style:UITableViewStyleGrouped];
        _tabelView.delegate = self;
        _tabelView.dataSource = self;
        _tabelView.estimatedRowHeight = 500;  //  随便设个不那么离谱的值
        _tabelView.rowHeight = UITableViewAutomaticDimension;
        [_tabelView registerNib:[UINib nibWithNibName:@"TKYMessageCell" bundle:nil] forCellReuseIdentifier:KMessageCelID];
        [_tabelView registerNib:[UINib nibWithNibName:@"TKYMessageDescribeCell" bundle:nil] forCellReuseIdentifier:KMessageDescribeCellID];
//        [_tabelView registerNib:[UINib nibWithNibName:@"TKYMessagePhotoOrVideoCell" bundle:nil] forCellReuseIdentifier:KMessagePhotoOrVideoCellID];

        [_tabelView registerClass:[TKYMessagePhotoOrVideoCell class] forCellReuseIdentifier:KMessagePhotoOrVideoCellID];
        
        [_tabelView registerNib:[UINib nibWithNibName:@"TKYMeansCell" bundle:nil] forCellReuseIdentifier:KMeansCellID];
    }
    return _tabelView;
}

- (NSArray *)setSectionOneData{
    NSMutableArray *dataArr = [NSMutableArray array];
    TKYMessageModel *taskModel = [[TKYMessageModel alloc]init];
    taskModel.tlitleStr = @"任务标题";
    taskModel.contentStr = @"xxxx";
    [dataArr addObject:taskModel];
    
    TKYMessageModel *typeModel = [[TKYMessageModel alloc]init];
    typeModel.tlitleStr = @"类型";
    typeModel.contentStr = @"安全";
     [dataArr addObject:typeModel];
    
    TKYMessageModel *questionModel = [[TKYMessageModel alloc]init];
    questionModel.tlitleStr = @"问题级别";
    questionModel.contentStr = @"重大";
     [dataArr addObject:questionModel];
    
    TKYMessageModel *scoreModel = [[TKYMessageModel alloc]init];
    scoreModel.tlitleStr = @"考核分数";
    scoreModel.contentStr = @"10";
     [dataArr addObject:scoreModel];
    
    TKYMessageModel *model1 = [[TKYMessageModel alloc]init];
    model1.tlitleStr = @"";
    model1.contentStr = @"";
    [dataArr addObject:model1];
    
    TKYMessageModel *model2 = [[TKYMessageModel alloc]init];
    model2.tlitleStr = @"";
    model2.contentStr = @"";
    [dataArr addObject:model2];
    
    TKYMessageModel *model3 = [[TKYMessageModel alloc]init];
    model3.tlitleStr = @"";
    model3.contentStr = @"";
    [dataArr addObject:model3];
    
    TKYMessageModel *dateModel = [[TKYMessageModel alloc]init];
    dateModel.tlitleStr = @"截至日期";
    dateModel.contentStr = @"2018-06-28";
    [dataArr addObject:dateModel];
    return dataArr.copy;
}

- (NSArray *)setPersonnelData{
    NSMutableArray *dataArr = [NSMutableArray array];
    TKYMessageModel *responsibilityModel = [[TKYMessageModel alloc]init];
    responsibilityModel.tlitleStr = @"责任人";
    responsibilityModel.contentStr = @"xxx";
    [dataArr addObject:responsibilityModel];
    
    TKYMessageModel *superviseModel = [[TKYMessageModel alloc]init];
    superviseModel.tlitleStr = @"督办人";
    superviseModel.contentStr = @"xxx";
    [dataArr addObject:superviseModel];
    
    TKYMessageModel *chenckModel = [[TKYMessageModel alloc]init];
    chenckModel.tlitleStr = @"验收人";
    chenckModel.contentStr = @"xxx";
    [dataArr addObject:chenckModel];
    
    TKYMessageModel *copyModel = [[TKYMessageModel alloc]init];
    copyModel.tlitleStr = @"抄送人";
    copyModel.contentStr = @"xxx";
    [dataArr addObject:copyModel];
    return dataArr.copy;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
